package com.zeta.eduservice.controller.Front;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zeta.commonutils.R;
import com.zeta.eduservice.entity.EduComment;
import com.zeta.eduservice.service.EduCommentService;
import com.zeta.utils.JwtUtils;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@RequestMapping("/eduservice/comment")

public class CommentFrontController {

//	 @Autowired
//	    private EduCommentService commentService;
//	    @Autowired
////	    private UcenterClient ucenterClient;
//
//	    //根据课程id查询评论列表
//	    @ApiOperation(value = "评论分页列表")
//	    @GetMapping("{page}/{limit}")
//	    public R index(
//	            @ApiParam(name = "page", value = "当前页码", required = true)
//	            @PathVariable Long page,
//
//	            @ApiParam(name = "limit", value = "每页记录数", required = true)
//	            @PathVariable Long limit,
//
//	            @ApiParam(name = "courseQuery", value = "查询对象", required = false)
//	                    String courseId) {
//	        Page<EduComment> pageParam = new Page<>(page, limit);
//
//	        QueryWrapper<EduComment> wrapper = new QueryWrapper<>();
//	        wrapper.eq("course_id",courseId);
//
//	        commentService.page(pageParam,wrapper);
//	        List<EduComment> commentList = pageParam.getRecords();
//
//	        Map<String, Object> map = new HashMap<>();
//	        map.put("items", commentList);
//	        map.put("current", pageParam.getCurrent());
//	        map.put("pages", pageParam.getPages());
//	        map.put("size", pageParam.getSize());
//	        map.put("total", pageParam.getTotal());
//	        map.put("hasNext", pageParam.hasNext());
//	        map.put("hasPrevious", pageParam.hasPrevious());
//	        return R.ok().data(map);
//	    }
//
//	    @ApiOperation(value = "添加评论")
//	    @PostMapping("auth/save")
//	    public R save(@RequestBody EduComment comment, HttpServletRequest request) {
//	        String memberId = JwtUtils.getMemberIdByJwtToken(request);
//	        if(StringUtils.isEmpty(memberId)) {
//	            return R.error().code(28004).message("请登录");
//	        }
//	        comment.setMemberId(memberId);
//
////	        UcenterMemberPay ucenterInfo = ucenterClient.getUcenterPay(memberId);
//
////	        comment.setNickname(ucenterInfo.getNickname());
////	        comment.setAvatar(ucenterInfo.getAvatar());
////
////	        commentService.save(comment);
//	        return R.ok();
	//    }
}
